import React, { Component, Fragment } from 'react';
import { Provider } from 'react-redux';
import {
  BrowserRouter,
  Switch,
  Route,
  Redirect
} from 'react-router-dom';
import {
  Container
} from 'react-bootstrap';

import { URL } from '../config';
import configureStore from '../stores/configureStore';

import Header from '../components/header';

import RegisterContainer from './passport/register';
import LoginContainer from './passport/login';
import FdpwdContainer from './passport/findpwd';
import DownloadContainer from './team/download';
import MainContent from './bash';
import ProjectContent from './project';
import ServsContent from './servs';
import NewVersion from './team/newVersion';

import "../containers/static/less/main.css";

const store = configureStore();

export default class extends Component {
  render () {
    return (
      <Provider store={store}>
        <BrowserRouter>
          <Switch>
            <Route path={URL.login_page} component={LoginContainer} />
            <Route path={URL.register_page} component={RegisterContainer} />
            <Route path={URL.findpwd_page} component={FdpwdContainer} />
            <Fragment>
              <Header />
              <Container>
                <Switch>
                  <Route path={URL.download_page} component={DownloadContainer} />
                  <Route path={URL.main_page} component={MainContent} />
                  <Route path={URL.serv_page} component={ServsContent} />
                  <Route path={URL.project_page} component={ProjectContent} />
                  <Redirect from="/*" to={URL.main_page} />
                </Switch>
                <NewVersion />
              </Container>
            </Fragment>
          </Switch>
        </BrowserRouter>
      </Provider>
    )
  }
}